﻿
-- ================================================
-- Remarks: Not part of standard Stored Proc
-- ================================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'Ivy_UserManagement_UserOrganizationRoleActivityAuthorization_GetAll')
	BEGIN
		DROP  Procedure  [Ivy_UserManagement_UserOrganizationRoleActivityAuthorization_GetAll]
	END

GO

CREATE PROCEDURE [Ivy_UserManagement_UserOrganizationRoleActivityAuthorization_GetAll] 
-- =============================================
-- Author:		<Mrinmoy>
-- Create date: <25/10/2015>
-- Description:	<Ivy_UserManagement_UserOrganizationRoleActivityAuthorization_GetAll>
-- =============================================
-- Add the parameters for the stored procedure here
	(
				@UserOrganizationCode varchar(50),
				@ActivityCode varchar(50),
				@UserLoginID varchar(50)

	)
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT OFF;

	--DECLARE @ActivityTypeCode varchar(50); 
	--SET @ActivityTypeCode = (SELECT [ActivityTypeCode] FROM [Sys_ActivityMaster] WHERE (ActivityCode = @ActivityCode)); 
	--If (@ActivityTypeCode = 'SEE') OR (@ActivityTypeCode = 'EDIT') OR (@ActivityTypeCode = 'REMOVE')
	--	BEGIN 
	--		-- jjgjg
	--	END 
	--ELSE
	--	BEGIN
			SELECT   [Sys_RoleActivity].[RoleKey], 
					 [UserOrganizationRole].[UserLoginID], 
					 [UserOrganizationRole].[UserOrganizationCode], 
					 [UserOrganizationRole].[UserOrganizationName], 
					 [Sys_RoleActivity].[RoleCode], 
					 [Sys_RoleActivity].[RoleName], 
					 [Sys_RoleActivity].[ActivityCode], 
					 [Sys_RoleActivity].[ActivityName]

			FROM     [UserOrganizationRole] LEFT OUTER JOIN [Sys_RoleActivity] 

			ON       [UserOrganizationRole].[UserRoleKey] = [Sys_RoleActivity].[RoleKey]

			WHERE       
				(
					([UserOrganizationRole].[UserOrganizationCode] = @UserOrganizationCode) AND 
					([Sys_RoleActivity].[ActivityCode] = @ActivityCode) AND 
					([UserOrganizationRole].[UserLoginID] = @UserLoginID)
				);
		--END
END
GO
